
import java.net.ServerSocket ;
import base.DataTracker;
import java.net.SocketException;
import java.io.IOException ;

public class Listen {
   ServerSocket listenSocket ;
   int port ;

   public Listen(int port){
	  DataTracker.init();
	  
	   
      this.port = port;

      try{
         listenSocket = new ServerSocket(port) ;
      }
      catch (SocketException e){
         System.out.println("Could not set timeout : " + e.getMessage());
      }
      catch (IOException e) {
         System.out.println("Could not listen on port : " + port);
      }
   }

   public void doListenLoop()
   {
	  new UpdateThread(180000,60000).start(); 
      while(true){
         try{
         new ProcessThread(listenSocket.accept()).start();
         }
         catch (IOException e) {
            System.out.println("Accept failed : " + port);
         }
      }
   }

   public static void main(String[] args){
      Listen listen = new Listen(60023);
      listen.doListenLoop() ;
   }
}
